package com.halfsword.creativecraft.sound;

import com.halfsword.creativecraft.CreativeCraft;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraftforge.common.util.ForgeSoundType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

public class Sounds {
    public static final DeferredRegister<SoundEvent> SOUND_EVENTS =
            DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, CreativeCraft.MOD_ID);
    public static final RegistryObject<SoundEvent> SPACE_DETECTOR_FOUND_ORE = registerSoundEvents("space_detector_found_ore");
    public static final RegistryObject<SoundEvent> SOUND_BLOCK_BREAK = registerSoundEvents("sound_block_break");
    public static final RegistryObject<SoundEvent> SOUND_BLOCK_STEP = registerSoundEvents("sound_block_step");
    public static final RegistryObject<SoundEvent> SOUND_BLOCK_FALL = registerSoundEvents("sound_block_fall");
    public static final RegistryObject<SoundEvent> SOUND_BLOCK_PLACE = registerSoundEvents("sound_block_place");
    public static final RegistryObject<SoundEvent> SOUND_BLOCK_HIT = registerSoundEvents("sound_block_hit");
    public static final ForgeSoundType SOUND_BLOCK_SOUNDS =new ForgeSoundType(1F,1F,Sounds.SOUND_BLOCK_BREAK,Sounds.SOUND_BLOCK_STEP,Sounds.SOUND_BLOCK_FALL,Sounds.SOUND_BLOCK_PLACE,Sounds.SOUND_BLOCK_HIT);


    public static final RegistryObject<SoundEvent> CORNFIELD_CHASE =registerSoundEvents("cornfield_chase");
    private static RegistryObject<SoundEvent> registerSoundEvents(String name) {
        return SOUND_EVENTS.register(name,()->SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(CreativeCraft.MOD_ID,name)));
    }

    public static void register(IEventBus eventBus) {
        SOUND_EVENTS.register(eventBus);

    }
}
